home *** CD-ROM | disk | FTP | other *** search
- Path: email.eag.unisysgsg.com!not-for-mail
- From: ssadra@maltese.eag.unisysgsg.com (Daniel R. Ascheman)
- Newsgroups: comp.lang.c
- Subject: CONVERTING INTEGER TO ASCII??????
- Date: 11 Mar 1996 06:55:05 -0600
- Organization: Loral Defense Systems-Eagan, Eagan, MN USA
- Message-ID: <4i17r9$2kn@maltese.eag.unisysgsg.com>
- NNTP-Posting-Host: maltese.eag.unisysgsg.com
- X-Newsreader: TIN [version 1.2 PL0]
-
- HI all,
-
- I need a way to convert an integer BACK to ascii so I can search for it
- in a file using the strstr() function in a file. I NEED it as an integer
- AND as an ascii, is it possible?
- As you know, strstr() is a char *, char * , so I can't use an int,
- and itoa() does not exist in UNIX - I am in a slight bind.
-
-
- EXAMPLE: (in semi-psuedo code)
-
-
-
- char num;
- int the number;
- int dan;
-
-
- printf("Enter your number\n");
- fgets(num, sizeof, stdin)
- sscan(do conversion, get the number);
-
-
- dan = srand(the number);
-
- printf("the num is %d\n", dan);
-
-
- now how do I convert int back to ascii so I can.....
-
-
- if ((fp = fopen("filename", "r")) == NULL) {
- printf("Can't open file\n");
- return(1);
- }
-
- /* NOW, LOOK FOR NUMBER IN A FILE */
-
- while ((fgets(line_in_file, 132, fp)) != NULL) {
- if (strstr(line_in_file, dan) != NULL) {
- fclose(fp);
- /* successful return */
- return(0);
- }
- }
- fclose(fp);
- /* non-successful return */
- return(2);
-
-
- If no conversion is possible in C/UNIX, anyone have any other ideas?
-
- I would greatly appreciate comments and possible solutions.
-
- thanks,
- Dan Ascheman
-
- <ssadra@maltese.eag.unisysgsg.com>
-